import { mapState, mapMutations } from 'vuex'

export default {
  data () {
    return {
      skuTableLoading: false
    }
  },
  computed: {
    ...mapState('commonComps/skuAssociatedModal', [
      'associatedRowList', 'showModal'
    ])
  },
  methods: {
    ...mapMutations('commonComps/skuAssociatedModal', [
      'ASSOCIATED_GOODS', 'CANCEL_GOODS', 'CHANGE_MODAL_SWITCH', 'CLEAR_GOODS', 'DESTORY_STATE'
    ]),
    /* 从map对象中获取所有对象，合成一个数组 */
    getListFromMapFn () {
      let values = this.associatedRowList.values()
      let rowList = []
      for (let item of values) {
        rowList.push(item)
      }
      return rowList
    },
    /* 获取row集合的SKUNo组成新的数组 */
    getSkuNoListFn (rowList, type) {
      let idName = type || 'skuNo'
      let skuNoList = rowList.map(value => {
        return value[idName]
      })
      return skuNoList
    }
  }
}
